import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { environment } from '@env/environment';
// layout
import { FnPassportComponent } from '../layout/fn-passport/fn-passport.component';
import { HeadquartersComponent } from '../layout/headquarters/headquarters.component';
// dashboard pages
// import { DashboardV1Component } from './dashboard/v1/v1.component';
// passport pages
import { FnZbLoginComponent } from './passport/fnzb-login/fnzb-login.component';
// single pages
import { Exception403Component } from './exception/403.component';
import { Exception404Component } from './exception/404.component';
import { Exception500Component } from './exception/500.component';
// guard
import { AutopartsDataCenterComponent } from './autoparts/autoparts-dataCenter/autoparts-dataCenter.component';
import { FnZbCanAuthProvide } from '@core/guard/fnzb-can-auth.provide';
import { CanAuthProvide } from '@core/guard/can-auth.provide';

import { HomePageComponent } from './dashboard/home-page/home-page.component';
import { HomePageFnComponent } from './dashboard/home-page-fn/home-page-fn.component';
// import { AssemblyDrawingComponent } from './assemblyDrawing/assemblyDrawing.component';
// import { ShoppingCarComponent } from './assemblyDrawing/shoppingCar/shoppingCar.component';


const routes: Routes = [
  {
    path: '', component: HeadquartersComponent, canActivate: [FnZbCanAuthProvide],
    children: [
      // 默认
      { path: '', redirectTo: 'dashboard/home-page', pathMatch: 'full' },
      { path: 'dashboard', redirectTo: 'dashboard/home-page', pathMatch: 'full' },
      { path: 'dashboard/home-page', component: HomePageComponent, data: { translate: 'dashboard_home-page' } },  // 总部
      // { path: 'dashboard/home-page', component: HomePageFnComponent, data: { translate: 'dashboard_home-page' } }, // 商家
      // { path: '', redirectTo: 'dashboard/v1', pathMatch: 'full' },
      // { path: 'dashboard', redirectTo: 'dashboard/v1', pathMatch: 'full' },
      // { path: 'dashboard/v1', component: DashboardV1Component, data: { translate: 'dashboard_v1' } },
      // 表单
      { path: 'form', loadChildren: './form/business-form.module#BusinessFormModule' },
      { path: 'report', loadChildren: './query/apes-query.module#ApesQueryModule' },
      // BI
      { path: 'bi', loadChildren: './bi/bi.module#BiModule' },
      // TMS
      { path: 'tms', loadChildren: './tms/tms.module#TmsModule' },
      // 智能报表
      { path: 'e-commerce', loadChildren: './e-commerce/e-commerce.module#ECommerceModule' },
      // 财务报表
      { path: 'financial', loadChildren: './financial/financial.module#FinancialModule' },
      // 基本设置
      { path: 'pro', loadChildren: './pro/pro.module#ProModule' },
      // 例子
      { path: 'demo', loadChildren: './demo/demo.module#DemoModule' },
      // 定制
      { path: 'custom', loadChildren: './custom/custom.module#CustomModule' },
    ],
  },

  // 爆炸图
  { path: 'autoparts', component: AutopartsDataCenterComponent, canActivate: [FnZbCanAuthProvide] },
  // 装配图
  {
    path: 'assemblyDrawing',
    canActivate: [FnZbCanAuthProvide],
    loadChildren: './assemblyDrawing/assemblyDrawing.module#AssemblyDrawingModule',
    // children: [
    //   { path: '', redirectTo: 'assemblyDrawing', pathMatch: 'full' },
    //   // { path: 'assemblyDrawing', component: AssemblyDrawingComponent },
    //   // { path: 'shopCar', component: ShoppingCarComponent },
    //   { path: 'assemblyDrawing', loadChildren: './assemblyDrawing/assemblyDrawing.module#AssemblyDrawingModule' },
    // ],
  },

  // passport
  {
    path: 'headquarters', component: FnPassportComponent,
    children: [
      { path: '', redirectTo: 'login', pathMatch: 'full' },
      { path: 'login', component: FnZbLoginComponent, data: { platform: 'zt', terminal: 'platformSystem' } },   // 总部
      // { path: 'login', component: FnZbLoginComponent, data: { platform: 'fn', terminal: 'merchantSystem' } },   // 商家
      // { path: 'login', component: FnZbLoginComponent, data: { platform: 'gys', terminal: 'supplierSystem' } },  // 供应商
    ],
  },
  { path: 'pad', loadChildren: './pad/pad.module#PadModule' },
  { path: 'analysis', loadChildren: './analysis/analysis.module#AnalysisModule' },
  // 异常
  { path: '403', component: Exception403Component },
  { path: '404', component: Exception404Component },
  { path: '500', component: Exception500Component },
  { path: '**', redirectTo: '404' },

];

@NgModule({
  imports: [RouterModule.forRoot(routes, { useHash: environment.useHash })],
  exports: [RouterModule],
})
export class RouteRoutingModule {
}

